#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
	char s[500000];
	long  k = 0, i = 0, n=0, j = 0,count=0,sum=0 ;
	
	char c1, c2;
	scanf("%ld", &k);
	scanf("%s %c %c", &s, &c1, &c2);
	n = strlen(s);
	for (i = k - 1; i < n; i++)
	{
		if (s[i - k + 1] == c1)
			count++;
		if (s[i] == c2)
			sum += count;
	}
	printf("%ld", sum);
	return 0;
}